package com.eh.erd.base.config;

import com.google.common.base.Predicates;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zhuyuanwei
 * @version 1.0
 * @date 2021/4/29 15:18
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {

    @Bean
    public Docket adminAipConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApiInfo())
                .select()
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build();
    }

    public ApiInfo adminApiInfo(){
        return new ApiInfoBuilder().title("E融贷后台管理系统API文档")
                .description("文档介绍了E融贷系统管理后台的各个模板的接口的调用与详情")
                .version("1.0")
                .contact(new Contact("zhuyuanwei","http://zhuyuanwei.com","zhuyuanwei8412@163.com")).build();
    }
    public ApiInfo webApiInfo(){
        return new ApiInfoBuilder().title("E融贷网站系统API文档")
                .description("文档介绍了E融贷网站的各个模板的接口的调用与详情")
                .version("1.0")
                .contact(new Contact("zhuyuanwei","http://zhuyuanwei.com","zhuyuanwei8412@163.com")).build();
    }


    @Bean
    public Docket webAipConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")
                .apiInfo(webApiInfo())
                .select()
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build();
    }

}
